package com.tony.inet;

import java.io.IOException;
import java.io.InputStream;
import java.net.*;

/**
 * @version V1.0  </br>
 * @ClassName InetAddressTest </br>
 * @Description TODO  </br>
 * @Author tonywang</br>
 * @DATE 2/25/2019 9:06 PM</br>
 */
public class InetAddressTest {
    public static void main(String[] args) throws IOException {
        URL url = new URL("http://www.sina.com.cn/");
        System.out.println("URL：" + url);
        System.out.println("getProtocol：" + url.getProtocol());
        System.out.println("getHost：" + url.getHost());
        System.out.println("getPort：" + url.getPort());
        System.out.println("getFile：" + url.getFile());
        System.out.println("getPath：" + url.getPath());
        System.out.println("getQuery：" + url.getQuery());

        InputStream inputStream = url.openStream();
        byte[] buff = new byte[1024];
        int len = inputStream.read(buff);
        String text = new String(buff,0,len);
        System.out.println(text);

        URLConnection connection = url.openConnection();
        System.out.println(connection);


    }
}
